const express = require("express");
const bodyParser = require("body-parser");
const router = express.Router();
const homeController = require("../controllers/home");
const uploadController = require("../controllers/upload");

let routes = (app) => {
  router.get("/", homeController.getHome);

  router.post("/upload", uploadController.uploadFiles);
  router.get("/files", uploadController.getListFiles);
  router.get("/getListFilesPage", uploadController.getListFilesPage);
  router.get("/files/:id", uploadController.download);

  router.post(
    "/updateImageWeightByWeight",
    bodyParser.json(),
    uploadController.updateImageWeightByWeight
  );

  router.post(
    "/getImageListByIds",
    bodyParser.json(),
    uploadController.getImageListByIds
  )

  return app.use("/", router);
};

module.exports = routes;
